<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\ActivityTypeController;
use App\Http\Controllers\ActivityController;
use App\Http\Controllers\ArticleController;
use App\Http\Controllers\GiftController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

Route::post('login', [LoginController::class, 'login']);

// 活动类型相关路由
Route::prefix('activity-types')->group(function () {
    Route::get('/', [ActivityTypeController::class, 'index']);
    Route::post('/', [ActivityTypeController::class, 'store']);
    Route::get('/{id}', [ActivityTypeController::class, 'show']);
    Route::put('/{id}', [ActivityTypeController::class, 'update']);
    Route::delete('/{id}', [ActivityTypeController::class, 'destroy']);
});

// 活动相关路由
Route::prefix('activities')->group(function () {
    Route::get('/', [ActivityController::class, 'index']);
    Route::post('/', [ActivityController::class, 'store']);
    Route::get('/{id}', [ActivityController::class, 'show']);
    Route::put('/{id}', [ActivityController::class, 'update']);
    Route::delete('/{id}', [ActivityController::class, 'destroy']);
});

// 文章相关路由
Route::prefix('articles')->group(function () {
    Route::get('/', [ArticleController::class, 'index']);
    Route::post('/', [ArticleController::class, 'store']);
    Route::get('/{id}', [ArticleController::class, 'show']);
    Route::put('/{id}', [ArticleController::class, 'update']);
    Route::delete('/{id}', [ArticleController::class, 'destroy']);
});

// 礼品管理路由
Route::prefix('gifts')->group(function () {
    Route::get('/', [GiftController::class, 'index']);
    Route::post('/', [GiftController::class, 'store']);
    Route::get('/{gift}', [GiftController::class, 'show']);
    Route::put('/{gift}', [GiftController::class, 'update']);
    Route::delete('/{gift}', [GiftController::class, 'destroy']);
    Route::patch('/{gift}/status', [GiftController::class, 'updateStatus']);
    Route::patch('/{gift}/stock', [GiftController::class, 'updateStock']);
});